package com.yuandian.ops.workbench.service.impl;

import com.yuandian.bpm.common.core.util.SpringContextHolder;
import com.yuandian.bpm.common.websocket.distribute.MessageDO;
import com.yuandian.bpm.common.websocket.distribute.RedisMessageDistributor;
import com.yuandian.ops.workbench.service.IWsService;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.concurrent.TimeUnit;

/**
 * 说明：
 *
 * @Author zfsn
 * @Date 2023/2/15 16:03
 */
@Service
public class WsServiceImpl implements IWsService {

	/*@PostConstruct
	public void init() {
		RedisMessageDistributor messageDistributor = SpringContextHolder.getBean(RedisMessageDistributor.class);
		new Thread(() -> {
			while (true) {
				String message = "content-" + System.currentTimeMillis();
				// 发给一个人
				// messageDistributor.distribute(MessageDO.singleMessage(1, message));
				// 发给多个人
				// messageDistributor.distribute(MessageDO.multipleMessage(CollUtil.newArrayList(1, 3, 4, 8), message));
				// 发给所有人
				messageDistributor.distribute(MessageDO.broadcastMessage(message));
				try {
					TimeUnit.SECONDS.sleep(5);
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}).start();
	}*/
}
